package server;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import com.google.gdata.client.GoogleService;
import com.google.gdata.data.Category;
import com.google.gdata.data.Entry;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.util.ServiceException;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;

import data.Data;

public class Test {
	public static void main(String[] args) throws IOException, ServiceException {
		
		
		Document document = Jsoup.parse(Utils.GetHtml("http://ap.ign.com/en/news/1563/Halo-4-Console-Available-for-Pre-Order", "utf-8"));
		
		
		
		String keyword="";
		String title="asdad";
		String str = document.select(".article-content").html().replaceAll("<p", "<div").replaceAll("</p", "</div"); 
		str=str.replaceAll("\\n", "");
		String description=str;
		
		
		
		Entry myEntry = new Entry();
		GoogleService myService = new GoogleService("blogger", "exampleCo-exampleApp-1");
		myService.setUserCredentials("victoriavaldes711@gmail.com", "048348234vdc");
		
		if(!keyword.equals(""))
		{
			Category category = new Category();
			category.setScheme("http://www.blogger.com/atom/ns#");
			category.setTerm(keyword);
			myEntry.getCategories().add(category);
		}
		
		myEntry.setTitle(new PlainTextConstruct(title));
		myEntry.setContent(new PlainTextConstruct(description));
		
		// Ask the service to insert the new entry
		URL postUrl = new URL("http://www.blogger.com/feeds/6461057792056862004/posts/default");
		myService.insert(postUrl, myEntry);

	}	
}
